package kt.com.bilin.coin.ui.dialog

import android.app.Dialog
import android.content.Context
import android.content.Intent
import com.bilin.coin.R
import kotlinx.android.synthetic.main.detail_wx_read.*
import kt.com.bilin.coin.common.clipboard


class WxReadDialog(context: Context, val link: String) : Dialog(context, R.style.dimLoadingdialog) {
    init {
        setContentView(R.layout.detail_wx_read)
        tvLink.text = link
        buttonConfirm.setOnClickListener {
            link.clipboard()
            context.packageManager.getLaunchIntentForPackage("com.tencent.mm")?.apply {
                val intent = Intent(Intent.ACTION_MAIN)
                intent.addCategory(Intent.CATEGORY_LAUNCHER)
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                intent.component = component
                context.startActivity(intent)
            }
        }
    }
}